Image scanning apparatus, and method and computer-readable medium therefor

ABSTRACT

An image scanning apparatus includes a controller configured to perform a light quantity adjustment determining process to determine whether a detection light quantity needs to be adjusted, based on adjustment determination values, in a black-white detectable position, a light quantity adjusting process to adjust the detection light quantity to maximize an adjustment difference value between a gradation value generated by scanning a white portion of a reference member and a gradation value generated by scanning a black portion of the reference member, a threshold calculating process to calculate a detection threshold based on a black value and a white value, and a reference position detecting process to detect a reference position by comparing, with the detection threshold, gradation values generated by scanning the reference member while illuminating the reference member with the detection light quantity.

CROSS-REFERENCE TO RELATED APPLICATION

This application claims priority under 35 U.S.C. § 119 from JapanesePatent Application No. 2017-052335 filed on Mar. 17, 2017. The entiresubject matter of the application is incorporated herein by reference.

BACKGROUND Technical Field

Aspects of the present disclosure are related to an image scanningapparatus, and a method and a computer-readable medium therefor.

Related Art

As a technique for an image scanning apparatus to perform documentscanning while moving an image sensor, it has been known setting a homeposition as a reference position for the image sensor by scanning areference mark.

For instance, an image scanning apparatus has been known that isconfigured to detect a white area and a black area of a reference markby comparing, with a black-white discrimination value, a differencevalue obtained by subtracting a black output value acquired by scanningthe black area from an output value.

SUMMARY

A secular change of the known apparatus may cause a reduction in thequantity of light emitted by the light source of the image sensor.Further, the secular change of the known apparatus may cause colordegradation of the black area of the reference mark. In such a case, anoutput value from the image sensor when scanning the white area of thereference mark might decrease due to the reduction in the light quantityof the light source. Even in this case, the black-white discriminationvalue may be previously set smaller to detect the white area and theblack area of the reference mark.

However, the black area of the reference mark is lighter in color thanbefore due to its color degradation. Hence, when the black-whitediscrimination value is previously set smaller, the known apparatusmight be unable to detect the black area of the reference mark.

Aspects of the present disclosure are advantageous to provide one ormore techniques, for an image scanning apparatus, which make it possibleto detect a reference member having a white portion and a black portion,even though an output value from an image scanner when scanning thewhite area decreases due to a secular change of a light source of theimage scanner, and an output value from the image scanner when scanningthe black area increases due to color degradation of the referencemember.

According to aspects of the present disclosure, an image scanningapparatus is provided, which includes an image scanner including a lightsource and a light receiver, the light receiver including lightreceiving elements arranged in line along a main scanning direction, theimage scanner being configured to illuminate a scanned target with lightemitted by the light source and receive reflected light from the scannedtarget by the light receiver, thereby generating gradation values, amover configured to move the image scanner along a sub scanningdirection perpendicular to the main scanning direction, a referencemember including a black portion, a white portion, and a black-whiteboundary between the black portion and the white portion, a position ofthe black-white boundary being a reference position for the imagescanner in the main scanning direction or the sub scanning direction, astorage configured to store a detection light quantity, the detectionlight quantity being a quantity of light to be emitted by the lightsource to detect the reference position, and a controller. Thecontroller is configured to perform a light quantity adjustmentdetermining process to determine whether the detection light quantityneeds to be adjusted, based on adjustment determination values, theadjustment determination values being gradation values generated whenthe image scanner illuminates the reference member with the detectionlight quantity in a black-white detectable position, the black-whitedetectable position being a position in the sub scanning direction wherethe image scanner faces the black portion and the white portion, a lightquantity adjusting process including adjusting, in response todetermining that the detection light quantity needs to be adjusted, thedetection light quantity to maximize an adjustment difference value, theadjustment difference value being a difference between a gradation valuegenerated when the image scanner scans the white portion whileilluminating the reference member in the black-white detectable positionand a gradation value generated when the image scanner scans the blackportion while illuminating the reference member in the black-whitedetectable position, and storing the adjusted detection light quantityinto the storage, a threshold calculating process to calculate adetection threshold based on a black value and a white value, the blackvalue being a gradation value generated when the image scanner scans theblack portion, the white value being a gradation value generated whenthe image scanner scans the white portion, and a reference positiondetecting process to, while moving the image scanner along the subscanning direction by the mover, detect the reference position bycomparing, with the detection threshold, gradation values generated whenthe image scanner scans the reference member while illuminating thereference member with the detection light quantity stored in thestorage.

According to aspects of the present disclosure, further provided is amethod implementable on a processor coupled with an image scanningapparatus. The image scanning apparatus includes an image scannerincluding a light source and a light receiver, the light receiverincluding light receiving elements arranged in line along a mainscanning direction, the image scanner being configured to illuminate ascanned target with light emitted by the light source and receivereflected light from the scanned target by the light receiver, therebygenerating gradation values, a mover configured to move the imagescanner along a sub scanning direction perpendicular to the mainscanning direction, a reference member including a black portion, awhite portion, and a black-white boundary between the black portion andthe white portion, a position of the black-white boundary being areference position for the image scanner in the main scanning directionor the sub scanning direction, and a storage configured to store adetection light quantity, the detection light quantity being a quantityof light to be emitted by the light source to detect the referenceposition. The method includes determining whether the detection lightquantity needs to be adjusted, based on adjustment determination values,the adjustment determination values being gradation values generatedwhen the image scanner illuminates the reference member with thedetection light quantity in a black-white detectable position, theblack-white detectable position being a position in the sub scanningdirection where the image scanner faces the black portion and the whiteportion, adjusting, in response to determining that the detection lightquantity needs to be adjusted, the detection light quantity to maximizean adjustment difference value, the adjustment difference value being adifference between a gradation value generated when the image scannerscans the white portion while illuminating the reference member in theblack-white detectable position and a gradation value generated when theimage scanner scans the black portion while illuminating the referencemember in the black-white detectable position, storing the adjusteddetection light quantity into the storage, calculating a detectionthreshold based on a black value and a white value, the black valuebeing a gradation value generated when the image scanner scans the blackportion, the white value being a gradation value generated when theimage scanner scans the white portion, and detecting, while moving theimage scanner along the sub scanning direction by the mover, thereference position by comparing, with the detection threshold, gradationvalues generated when the image scanner scans the reference member whileilluminating the reference member with the detection light quantitystored in the storage.

According to aspects of the present disclosure, further provided is anon-transitory computer-readable medium storing computer-readableinstructions that are executable by a processor coupled with an imagescanning apparatus. The image scanning apparatus includes an imagescanner including a light source and a light receiver, the lightreceiver including light receiving elements arranged in line along amain scanning direction, the image scanner being configured toilluminate a scanned target with light emitted by the light source andreceive reflected light from the scanned target by the light receiver,thereby generating gradation values, a mover configured to move theimage scanner along a sub scanning direction perpendicular to the mainscanning direction, a reference member including a black portion, awhite portion, and a black-white boundary between the black portion andthe white portion, a position of the black-white boundary being areference position for the image scanner in the main scanning directionor the sub scanning direction, and a storage configured to store adetection light quantity, the detection light quantity being a quantityof light to be emitted by the light source to detect the referenceposition. The instructions are configured to, when executed by theprocessor, cause the processor to perform a light quantity adjustmentdetermining process to determine whether the detection light quantityneeds to be adjusted, based on adjustment determination values, theadjustment determination values being gradation values generated whenthe image scanner illuminates the reference member with the detectionlight quantity in a black-white detectable position, the black-whitedetectable position being a position in the sub scanning direction wherethe image scanner faces the black portion and the white portion, a lightquantity adjusting process including adjusting, in response todetermining that the detection light quantity needs to be adjusted, thedetection light quantity to maximize an adjustment difference value, theadjustment difference value being a difference between a gradation valuegenerated when the image scanner scans the white portion whileilluminating the reference member in the black-white detectable positionand a gradation value generated when the image scanner scans the blackportion while illuminating the reference member in the black-whitedetectable position, and storing the adjusted detection light quantityinto the storage, a threshold calculating process to calculate adetection threshold based on a black value and a white value, the blackvalue being a gradation value generated when the image scanner scans theblack portion, the white value being a gradation value generated whenthe image scanner scans the white portion, and a reference positiondetecting process to, while moving the image scanner along the subscanning direction by the mover, detect the reference position bycomparing, with the detection threshold, gradation values generated whenthe image scanner scans the reference member while illuminating thereference member with the detection light quantity stored in thestorage.

BRIEF DESCRIPTION OF THE ACCOMPANYING DRAWINGS

FIG. 1 schematically shows an internal configuration of an imagescanning apparatus in an illustrative embodiment according to one ormore aspects of the present disclosure.

FIG. 2 is a plane view of a document table of the image scanningapparatus in the illustrative embodiment according to one or moreaspects of the present disclosure.

FIG. 3 shows a configuration of a reference member attached onto atransparent plate of the document table in the illustrative embodimentaccording to one or more aspects of the present disclosure.

FIG. 4 is a block diagram schematically showing an electricalconfiguration of the image scanning apparatus in the illustrativeembodiment according to one or more aspects of the present disclosure.

FIGS. 5A and 5B are flowcharts showing a procedure of an activatingprocess in the illustrative embodiment according to one or more aspectsof the present disclosure.

FIG. 6 is a flowchart showing a procedure of a precise-positiondetecting process in the illustrative embodiment according to one ormore aspects of the present disclosure.

FIGS. 7A and 7B are flowcharts showing a procedure of a rough-positiondetecting process in the illustrative embodiment according to one ormore aspects of the present disclosure.

FIG. 8 is a flowchart showing a procedure of a detection light quantityadjusting process in the illustrative embodiment according to one ormore aspects of the present disclosure.

FIG. 9 is a flowchart showing a procedure of a threshold calculatingprocess in the illustrative embodiment according to one or more aspectsof the present disclosure.

FIG. 10 is a flowchart showing a procedure of a shutdown process in theillustrative embodiment according to one or more aspects of the presentdisclosure.

FIG. 11 is a flowchart showing a procedure of a storing process to storea first maximum value and a second minimum value, in the illustrativeembodiment according to one or more aspects of the present disclosure.

DETAILED DESCRIPTION

It is noted that various connections are set forth between elements inthe following description. It is noted that these connections in generaland, unless specified otherwise, may be direct or indirect and that thisspecification is not intended to be limiting in this respect. Aspects ofthe present disclosure may be implemented on circuits (such asapplication specific integrated circuits) or in computer software asprograms storable on computer-readable media including but not limitedto RAMs, ROMs, flash memories, EEPROMs, CD-media, DVD-media, temporarystorage, hard disk drives, floppy drives, permanent storage, and thelike.

<Configuration of Image Scanning Apparatus>

FIG. 1 is a front view of an image scanning apparatus SM according toaspects of the present disclosure. FIG. 2 is a plane view of a documenttable DT. It is noted that in the following description, a right-handside in FIG. 1 will be defined as a downstream side in a sub scanningdirection. A lower side in FIG. 2 will be defined as a downstream sidein a main scanning direction. A right-hand side in FIG. 2 will bedefined as a downstream side in the sub scanning direction. The imagescanning apparatus SM includes the document table DT and a documentcover CV. The document table DT includes a main body MB and atransparent plate TP. The main body MB is configured to accommodatevarious members (e.g., the transparent plate TP and an image scanner20). The transparent plate TP is disposed inside the main body MB andfixedly attached to the main body MB. The transparent plate TP isconfigured to support a document sheet placed thereon. The documentcover CV is disposed above the main body MB. The document cover CV isopenable and closable relative to the main body MB. The document coverCV includes swing shafts 28 disposed at a rear end portion (i.e., a farside portion in a direction perpendicular to a flat surface of FIG. 1,and an upper end portion in FIG. 2) of the main body MB. The documentcover CV is configured to swing around the swing shafts 28 so as to beopened and closed from a front end (i.e., a near side portion in thedirection perpendicular to the flat surface of FIG. 1, and a lower endportion in FIG. 2) of the main body MB.

The image scanning apparatus SM further includes the image scanner 20.The image scanner 20 is disposed below the transparent plate TP, insidethe main body MB. The image scanner 20 is movable along the sub scanningdirection (i.e., the left-to-right direction in FIG. 1) relative to themain body MB. The image scanner 20 is configured to scan an image of adocument sheet placed on the transparent plate TP. The image scanner 20includes a CIS (“CIS” is an abbreviated form of “contact image sensor”).More specifically, the image scanner 20 includes a light source 21, arod lens 24, and a light receiver 22. The light source 21 includes atleast a green LED (“LED” is an abbreviated form of “light-emittingdiode”). The light source 21 is configured to emit light toward thetransparent plate TP. The rod lens 24 is configured to receive reflectedlight of the light emitted by the light source 21.

The light receiver 22 includes 2592 photoelectric conversion elements 23arranged along the main scanning direction. The light receiver 22further incorporates therein a shift register (not shown) and anamplifier (not shown). An output from each photoelectric conversionelement 23 corresponds to a quantity of light received by each of pixelsarranged along the main scanning direction. A head pixel of thephotoelectric conversion elements 23 is a pixel positioned upstream ofany other pixels in the main scanning direction shown in FIG. 2. A finalpixel of the photoelectric conversion elements 23 is a pixel positioneddownstream of any other pixels in the main scanning direction shown inFIG. 2. In the illustrative embodiment, a single line is a pixel groupincluding a plurality of pixels from the head pixel to the final pixel.An interval between each two of mutually-adjacent lines in the subscanning direction is 300 DPI. An interval between each two ofmutually-adjacent photoelectric conversion elements 23 in the mainscanning direction is 300 DPI.

As shown in FIG. 2, an upper surface of the document table DT includesan upper surface of the main body MB and an upward-exposed surface ofthe transparent plate TP. The upward-exposed surface of the transparentplate TP is exposed toward the document cover CV. The swing shafts 28are disposed at the main body MB. The transparent plate TP is indicatedby an alternate long and short dash line in FIG. 2. The transparentplate TP is formed in a rectangular shape having long sides along thesub scanning direction and short sides along the main scanningdirection. The upward-exposed surface of the transparent plate TP isindicated by a solid line in FIG. 2. The most upstream position of theupward-exposed surface of the transparent plate TP in both the mainscanning direction and the sub scanning direction is a base position BP.The base position BP is a reference position in the main scanningdirection, and is a reference position in the sub scanning direction. Inthe main scanning direction, the base position BP is a below-mentionedscanning start position RSP. In the sub scanning direction, the baseposition BP is located 200 lines downstream of a below-mentioned homeposition HP. The most downstream position of the upward-exposed surfaceof the transparent plate TP in the sub scanning direction is a maximumscanning position MSE. The maximum scanning position MSE is located 3700lines downstream of the below-mentioned home position HP in the subscanning direction. On the transparent plate TP, a document sheet GS isplaced with the base position BP as a reference point. In FIG. 2, astate where an A4-size document sheet GS is placed with a longitudinaldirection thereof along the sub scanning direction is shown by analternate long and two short dashes line. The swing shafts 28 areconfigured to rotate when the document cover CV is opened and closed.The two swing shafts 28 are disposed at two places at an upstream endportion of the main body MB in the main scanning direction,respectively.

The image scanning apparatus SM further includes a reference member BMfixedly attached onto the upper surface of the transparent plate TP. Thereference member BM is disposed at an upstream end portion (i.e., a leftend portion in FIG. 2) of the transparent plate TP in the sub scanningdirection. As shown in FIG. 3, the reference member BM includes a whitearea WE and a black area BE. The reference member BM is formed in arectangular shape having a length of 220 mm in the main scanningdirection and a length of 10.2 mm in the sub scanning direction. Theblack area BE is hatched with oblique lines in FIG. 3. The black area BEis a most upstream area of the reference member BM in the main scanningdirection, and is a most downstream area of the reference member BM inthe sub scanning direction. The black area BE is formed in a rectangularshape having a length of 20 mm in the main scanning direction and alength of 5.1 mm in the sub scanning direction. The white area WE is anarea left by removing the black area BE from the reference member BM. Aboundary, extending along the main scanning direction, between the blackarea BE and the white area WE is a sub black-white boundary SSB. Aboundary, extending along the sub scanning direction, between the blackarea BE and the white area WE is a main black-white boundary MSB. In theillustrative embodiment, the length (i.e., 220 mm) of the referencemember BM in the main scanning direction is slightly longer than 218 mmthat is a scanning range of the image scanner 20 in the main scanningdirection. There is a backlash or fitting looseness at a joint portionof the image scanner 20. Therefore, the image scanner 20 might bedisplaced up to 1 mm relative to the reference member BM in the mainscanning direction. Even in such a case, the reference member BM isalways opposed to the image scanner 20 within the scanning range of theimage scanner 20.

Subsequently, referring to FIG. 3, a first storing area ME1, a secondstoring area ME2, a third storing area ME3, the home position HP, and alight quantity adjustment position IAP will be described. The homeposition HP is a position in the sub scanning direction. Morespecifically, the home position HP is a position located 300 linesupstream of the sub black-white boundary SSB in the sub scanningdirection. A position of the sub black-white boundary SSB is a positionof the image scanner 20 when an affirmative determination is made in abelow-mentioned process UA3 (UA3: Yes) or a position of the imagescanner 20 when an affirmative determination is made in abelow-mentioned process UB11 (UB11: Yes). The image scanner 20 ismovable along the sub scanning direction with the home position HP as areference position. The light quantity adjustment position IAP is aposition in the sub scanning direction. More specifically, the lightquantity adjustment position IAP is located 60 lines downstream of thehome position HP in the sub scanning direction. Below-mentionedprocesses U10 and D6 are performed when the image scanner 20 is in thelight quantity adjustment position IAP. A first range MR1 is a range inthe main scanning direction. More specifically, the first range MR1 is arange of the head pixel (i.e., a first pixel) to a 200^(th) pixel of thephotoelectric conversion elements 23 in the main scanning direction. Asecond range MR2 is a range in the main scanning direction. Morespecifically, the second range MR2 is a range of a 260 pixel to a460^(th) pixel of the photoelectric conversion elements 23 in the mainscanning direction. A third range MR3 is a range in the main scanningdirection. More specifically, the third range MR3 is a range of a201^(st) pixel to a 260^(th) pixel of the photoelectric conversionelements 23 in the main scanning direction.

As indicated by an alternate long and short dash line in FIG. 3, thefirst storing area ME1 is defined by the first range MR1 in the mainscanning direction and a range from a first specific position located 20lines upstream of the light quantity adjustment position IAP in the subscanning direction to a second specific position located 40 linesdownstream of the first specific position in the sub scanning direction.As indicated by an alternate long and two short dashes line in FIG. 3,the second storing area ME2 is defined by the second range MR2 in themain scanning direction and a range from the first specific positionlocated 20 lines upstream of the light quantity adjustment position IAPin the sub scanning direction to the second specific position located 40lines downstream of the first specific position in the sub scanningdirection. As indicated by a dashed line in FIG. 3, the third storingarea ME3 is defined by the first range MR1 in the main scanningdirection and a range from a first particular position located 20 linesupstream of the home position HP in the sub scanning direction to asecond particular position located 40 lines downstream of the firstparticular position in the sub scanning direction. In the illustrativeembodiment, as described above, the image scanner 20 might be displacedup to 1 mm relative to the reference member BM in the main scanningdirection. Further, in a below-mentioned process U6, the sub black-whiteboundary SSB is detected every 8 lines. Therefore, the image scanner 20might be displaced up to 8 lines relative to the reference member BM inthe sub scanning direction. Even in such a case, the first storing areaME1 is set not to protrude out of the black area BE, and the second andthird storing areas ME2 and ME3 are set not to protrude out of the whitearea WE.

<Electrical Configuration of Image Scanning Apparatus>

An electrical configuration of the image scanning apparatus SM will bedescribed with reference to FIG. 4. As shown in FIG. 4, the imagescanning apparatus SM includes a CPU 30, a ROM 31, a RAM 32, a flash ROM33, a device controller 34, an analog front end (hereinafter referred toas an “AFE”) 35, an image processor 36, and a drive circuit 37. Theaforementioned elements are connected with an operation mechanism OM anda display mechanism DM via a bus 38. The operation mechanism OM includesa plurality of operable keys such as a start button and a determinationbutton. By operating the operation mechanism OM, a user may inputvarious instructions into the image scanning apparatus SM. The displaymechanism DM includes a display configured to display various kinds ofinformation.

The ROM 31 stores therein programs 31A for causing the image scanningapparatus SM to perform various processes (e.g., a below-mentionedactivating process, a below-mentioned shutdown process, and subroutineprocesses). The CPU 30 is configured to control each of elementsincluded in the image scanning apparatus SM in accordance with theprograms 31A read out of the ROM 31. The flash ROM 33 is a non-volatilerewritable memory configured to store various types of data (e.g., dataacquired in the activating process) generated in control processes bythe CPU 30. The RAM 32 is configured to temporarily store calculationresults generated in control processes by the CPU 30.

The device controller 34 is connected with the image scanner 20. Thedevice controller 34 is configured to transmit, to the light source 21,a signal for turning on or off the light source 21 and a signal forcontrolling an electrical current to be supplied to the light source 21,based on instructions from the CPU 30. Further, the device controller 34is configured to transmit, to the light receiver 22, a serial-in signalSI for concurrently transferring electrical signals from thephotoelectric conversion elements 23 to the shift register (not shown)and a clock signal CLK for causing the shift register to sequentiallyoutput electrical signals, based on instructions from the CPU 30. Inresponse to receipt of those signals from the device controller 34, theimage scanner 20 turns on the light source 21, and transmits to the AFE35 an analog signal corresponding to a quantity of light received by thelight receiver 22.

The AFE 35 is connected with the image scanner 20. The AFE 35 isconfigured to convert the analog signal received from the image scanner20 into digital data, based on an instruction from the CPU 30. The AFE35 has a predetermined input range and a predetermined resolution. Forinstance, the resolution may be 8 bits (i.e., gradations from 0 to 255).In this case, the AFE 35 may convert the analog signal received from theimage scanner 20 into 8-bit gradation data (ranging from 0 to 255) asdigital data. The digital data obtained via the conversion by the AFE 35is transmitted to the image processor 36.

The image processor 36 includes an ASIC specific for image processing.The image processor 36 is configured to apply black correction to thedigital data. Nonetheless, the image processor 36 may be selectively setinto one of a mode to enable the black correction and a mode to disablethe black correction. When set into the mode to enable the blackcorrection, the image processor 36 applies the black correction tosubtract black correction data from the digital data and generates 8-bitgradation values GV. The gradation values GV are stored into the RAM 32via the bus 38. Meanwhile, when set into the mode to disable the blackcorrection, the image processor 36 stores the 8-bit digital data intothe RAM 32. In the image processor 36, black correction data is set forthe black correction.

The drive circuit 37 is connected with a carrying motor MT. The drivecircuit 37 is configured to drive the carrying motor MT based on adriving instruction from the CPU 30. The drive circuit 37 rotates thecarrying motor MT in accordance with a rotational quantity and arotational direction specified by the driving instruction. In responseto the carrying motor MT rotating by a particular rotational quantity, amoving mechanism MM rotates by a particular angle, thereby moving theimage scanner 20 over a particular distance in the sub scanningdirection.

<Operations by Image Scanning Apparatus>

(Activating Process)

Subsequently, operations by the image scanning apparatus SM will bedescribed with reference to the accompanying drawings. The imagescanning apparatus SM is configured to perform the activating processand the shutdown process. The activating process is performed inresponse to the image scanning apparatus SM being powered on. Theshutdown process is performed to power off the image scanning apparatusSM. Processes U1 to U15 in the activating process (see FIGS. 5A and 5B)and processes D1 to D8 in the shutdown process (see FIG. 10) areperformed by the CPU 30 executing one or more programs 31A stored in theROM 31.

The activating process (see FIGS. 5A and 5B) is started in response tothe image scanning apparatus SM being powered on from a shut-down state.Namely, the CPU 30 starts the activating process in response to receiptof an instruction representing that the image scanning apparatus SM hasbeen powered on.

The CPU 30 initializes the device controller 34 and the image processor36 (U1). Specifically, the CPU 30 acquires, from the flash ROM 33,settings for the clock signal CLK and the serial-in signal SI that aresuitable for a scanning resolution of 300 DPI in the main scanningdirection and a scanning resolution of 300 DPI in the sub scanningdirection. Then, the CPU 30 applies the acquired settings to the devicecontroller 34. The CPU 30 acquires, from the flash ROM 33, a detectionlight quantity DI of the light source 21. Then, the CPU 30 applies theacquired detection light quantity DI to the device controller 34. TheCPU 30 configures settings for the black correction into the imageprocessor 36. The CPU 30 acquires black correction data from the flashROM 33, and sets the acquired black correction data into the imageprocessor 36. In the illustrative embodiment, for instance, the blackcorrection data may be a smallest value included in single-line digitaldata for a black color that has been acquired at the time of factoryshipping. The detection light quantity DI may include or may bedetermined by a value of an electrical current to be supplied to thelight source 21 and a period of time during which the light source 21 iskept turned on. More specifically, the detection light quantity DI mayinclude or may be determined by a maximum value of an electrical currentsuppliable to the light source 21 and a longest period of time duringwhich the light source 21 may be kept turned on among time intervals ofthe serial-in signal SI, at the time of factory shipping. The detectionlight quantity DI is updated and stored in the below-mentioned processesU10 and D6.

The CPU 30 calculates a position threshold PTH (U2). Specifically, theCPU 30 acquires a first maximum value MX1 and a second minimum value MN2from the flash ROM 33. The CPU 30 averages the first maximum value MX1and the second minimum value MN2, thereby calculating the positionthreshold PTH. The CPU 30 sets the position threshold PTH as a subposition threshold SPTH, and sets the position threshold PTH as a mainposition threshold MPTH. In the illustrative embodiment, the firstmaximum value MX1 and the second minimum value MN2 may be stored intothe flash ROM 33 at the time of factory shipping, and are updated andheld in the flash ROM 33 in a process U12 or the process D8.

The CPU 30 performs a precise-position detecting process (U3). Theprecise-position detecting process U3 will be described in detail later.A general outline of the process U3 will be provided here. The CPU 30transmits, to the drive circuit 37, a driving instruction to move theimage scanner 20 downstream in the sub scanning direction. The CPU 30determines whether a first minimum value MN1 in the first range MR1 isless than the sub position threshold SPTH. The CPU 30 stores, into theRAM 32, a position that is located 30 lines upstream, in the subscanning direction, of a position of the image scanner 20 where it isdetermined that the first minimum value MN1 in the first range MR1 isless than the sub position threshold SPTH, as the home position HP. TheCPU 30 transmits, to the drive circuit 37, a driving instruction to movethe image scanner 20 downstream in the sub scanning direction. In thethird range MR3, the CPU 30 searches for a position of a specific pixelat which the gradation value GV becomes less than the main positionthreshold MPTH from a value equal to or more than the main positionthreshold MPTH, in the upstream direction along the main scanningdirection from a 260^(th)-pixel position (on the basis of the head pixelas the first pixel) in the main scanning direction. The CPU 30determines, as a boundary position BDP, the found position of thespecific pixel at which the gradation value GV has changed from a valueequal to or more than the main position threshold MPTH to a value lessthan the main position threshold MPTH. The CPU 30 acquires, as aboundary data group BDG, gradation values GV of 10 pixels that arelocated upstream of the boundary position BDP in the main scanningdirection. The CPU 30 determines whether all of the gradation values GVin the boundary data group BDG represent the black color. Whendetermining that all of the gradation values GV in the boundary datagroup BDG represent the black color, the CPU 30 stores, into the RAM 32,a position that is located 185 pixels upstream of the boundary positionBDP in the main scanning direction, as the scanning start position RSP.When storing the home position HP and the scanning start position RSPinto the RAM 32, the CPU 30 sets a position flag PFG to “ON.” Meanwhile,when not storing at least one of the home position HP and the scanningstart position RSP into the RAM 32, the CPU 30 sets the position flagPFG to “OFF.”

The CPU 30 determines whether the position flag PFG is “ON” (U4). Whendetermining that the position flag PFG is not “ON” (U4: No), the CPU 30goes to a process U6. Meanwhile, when determining that the position flagPFG is “ON” (U4: Yes), the CPU 30 goes to a process U5. In the processU5, the CPU 30 transmits, to the drive circuit 37, a driving instructionto move the image scanner 20 to the home position HP stored in the RAM32 (U5). After completion of the process U5, the CPU 30 terminates theactivating process.

The CPU 30 performs a rough-position detecting process (U6). Therough-position detecting process U6 will be described in detail later. Ageneral outline of the process U6 will be provided here. The CPU 30transmits, to the drive circuit 37, a driving instruction to move theimage scanner 20 upstream in the sub scanning direction. The CPU 30determines whether the first range MR1 is black and the second range MR2is white. The CPU 30 moves the image scanner 20 just over a distance of8 lines upstream in the sub scanning direction from a position in thesub scanning direction where it is determined that the first range MR1is black and that the second range MR2 is white. The CPU 30 averages allof the gradation values GV included in the first range MR1, and storesthe average value as a black average BAVE into the RAM 32. The CPU 30averages all of the gradation values GV included in the second rangeMR2, and stores the average value as a white average WAVE into the RAM32. The CPU 30 calculates a black-white difference value BWdif bysubtracting the black average BAVE from the white average WAVE. The CPU30 transmits, to the drive circuit 37, a driving instruction to move theimage scanner 20 upstream in the sub scanning direction. The CPU 30determines whether the first range MR1 is white and the second range MR2is white. The CPU 30 stores, into the RAM 32, a position that is located30 lines upstream, in the sub scanning direction, of a position where itis determined that the first range MR1 is white and that the secondrange MR2 is white, as the home position HP. When storing the homeposition HP, the CPU 30 sets the position flag PFG to “ON.” Meanwhile,when not storing the home position HP, the CPU 30 sets the position flagPFG to “OFF.”

The CPU 30 determines whether the position flag PFG is “ON” (U7). Whendetermining that the position flag PFG is not “ON” (U7: No), the CPU 30goes to a process U15. Meanwhile, when determining that the positionflag PFG is “ON” (U7: Yes), the CPU 30 goes to a process U8.

The CPU 30 determines whether the black average BAVE is less than afirst threshold TH1 (U8). When determining that the black average BAVEis not less than the first threshold TH1 (U8: No), the CPU 30 goes to aprocess U10. Meanwhile, when determining that the black average BAVE isless than the first threshold TH1 (U8: Yes), the CPU 30 goes to aprocess U9. In the illustrative embodiment, the first threshold TH1 maybe 30. The first threshold TH1 (i.e., 30) is a maximum value of varyinggradation values GV acquired by single-line scanning of the black coloralong the main scanning direction. Thus, when the first threshold TH1 isset to 30, it is possible to accurately determine whether a black outputvalue (i.e., an output value from the image scanner 20 when scanning theblack area BE of the reference member BM) becomes higher due to colordegradation caused by aging of the black area BE, without makingerroneous determination owing to variation of gradation values GVacquired by scanning the black area BE.

The CPU 30 determines whether a difference between the black-whitedifference value BWdif and the position threshold PTH is equal to ormore than a third threshold TH3 (U9). Specifically, the CPU 30determines whether a value obtained by subtracting the positionthreshold PTH from the black-white difference value BWdif is equal to ormore than the third threshold TH3. When determining that the differencebetween the black-white difference value BWdif and the positionthreshold PTH is equal to or more than the third threshold TH3 (U9:Yes), the CPU 30 goes to a process U11. Meanwhile, when determining thatthe difference between the black-white difference value BWdif and theposition threshold PTH is not equal to or more than the third thresholdTH3 (U9: No), the CPU 30 goes to the process U10. In the illustrativeembodiment, the third threshold TH3 may be 25. The third threshold TH3(i.e., 25) is about 10% of the count of the gradations for gradationvalues GV. By determining whether the difference between the black-whitedifference value BWdif and the position threshold PTH is equal to ormore than 10% of the count of the gradations, it is possible to detectthe reference member BM even when the black output value or a whiteoutput value (i.e., an output value from the image scanner 20 whenscanning the white area WE of the reference member BM) slightly changesdue to a secular change of the reference member BM.

In response to the negative determination (U9: No) in the process U9 orthe negative determination (U8: No) in the process U8, the CPU 30performs a detection light quantity adjusting process (U10). Thedetection light quantity adjusting process U10 will be described indetail later. A general outline of the process U10 will be providedhere. The CPU 30 transmits, to the drive circuit 37, a drivinginstruction to move the image scanner 20 to the light quantityadjustment position IAP. The CPU 30 acquires, as a detection lightquantity DI, a light quantity to maximize a value obtained bysubtracting a maximum one of gradation values GV included in the firstrange MR1 from a minimum one of gradation values GV included in thesecond range MR2. Then, the CPU 30 stores the detection light quantityDI into the flash ROM 33. After completion of the process U10, the CPU30 goes to a process U12.

When determining that the difference between the black-white differencevalue BWdif and the position threshold PTH is equal to or more than thethird threshold TH3 (U9: Yes), the CPU 30 determines whether the whiteaverage WAVE is equal to or more than a second threshold TH2 (U11). Whendetermining that the white average WAVE is equal to or more than thesecond threshold TH2 (U11: Yes), the CPU 30 goes to a process U13.Meanwhile, when determining that the white average WAVE is not equal toor more than the second threshold TH2 (U11: No), the CPU 30 goes to aprocess U12. In the illustrative embodiment, the second threshold TH2may be 127, which is an integer part of a value obtained by dividing theupper limit (i.e., 255) of the 8-bit gradation data by 2. Assuming thata maximum value of outputs from the image scanner 20 during single-linescanning of a white color is expressed as 100%, a minimum value of theoutputs from the image scanner 20 during the single-line scanning of thewhite color might be 50%. Even in such a case, when the second thresholdTH2 is set to 127, it is possible to determine whether the white outputvalue (i.e., an output value from the image scanner 20 when scanning thewhite area WE of the reference member BM) is reduced due to colordegradation caused by aging of the white area WE, without makingerroneous determination due to variation of gradation values GV acquiredby single-line scanning of the white area WE.

In response to the negative determination (U11: No) in the process U11or completion of the process U10, the CPU 30 performs a thresholdcalculating process (U12). The threshold calculating process U12 will bedescribed in detail later. A general outline of the process U12 will beprovided here. The CPU 30 transmits, to the drive circuit 37, a drivinginstruction to move the image scanner 20 to the home position HP. TheCPU 30 acquires a third data group DG3 of gradation values GV within thethird storing area ME3. The CPU 30 stores, into the flash ROM 33, aminimum one of gradation values GV included in the acquired third datagroup DG3, as a third minimum value MN3. The CPU 30 transmits, to thedrive circuit 37, a driving instruction to move the image scanner 20 tothe light quantity adjusting position IAP. The CPU 30 acquires gradationvalues GV within the first storing area ME1 as a first data group DG1,and acquires gradation values GV within the second storing area ME2 as asecond data group DG2. The CPU 30 stores, into the flash ROM 33, amaximum one of the gradation values GV included in the acquired firstdata group DG1, as a first maximum value MX1. Further, the CPU 30stores, into the flash ROM 33, a minimum one of the gradation values GVincluded in the acquired second data group DG2, as a second minimumvalue MN2. The CPU 30 calculates an average of the first maximum valueMX1 and the second minimum value MN2, and stores the calculated averageas the main position threshold MPTH into the RAM 32. The CPU 30calculates an average of the first maximum value MX1 and the thirdminimum value MN3, and stores the calculated average as the sub positionthreshold SPTH into the RAM 32.

In response to the affirmative determination (U11: Yes) in the processU11 or completion of the process U12, the CPU 30 performs aprecise-position detecting process (U13). The precise-position detectingprocess U13 will be described in detail later. A general outline of theprocess U13 will be provided here. The CPU 30 transmits, to the drivecircuit 37, a driving instruction to move the image scanner 20downstream in the sub scanning direction. The CPU 30 determines whetherthe first minimum value MN1 in the first range MR1 is less than the subposition threshold SPTH. The CPU 30 stores, into the RAM 32, a positionthat is located 30 lines upstream, in the sub scanning direction, of aposition where it is determined that the first minimum value MN1 in thefirst range MR1 is less than the sub position threshold SPTH, as thehome position HP. The CPU 30 transmits, to the drive circuit 37, adriving instruction to move the image scanner 20 downstream in the subscanning direction. In the third range MR3, the CPU 30 searches for aposition of a pixel of which a value has changed from a value equal toor more than the main position threshold MPTH to a value less than themain position threshold MPTH, in the upstream direction along the mainscanning direction from the 260^(th)-pixel position in the main scanningdirection. The CPU 30 determines the position of the pixel found via thesearch, as a boundary position BDP. The CPU 30 acquires, as the boundarydata group BDG, gradation values GV of 10 pixels that are locatedupstream of the boundary position BDP in the main scanning direction.The CPU 30 determines whether all of the gradation values GV included inthe boundary data group BDG represent the black color. When determiningthat all of the gradation values GV included in the boundary data groupBDG represent the black color, the CPU 30 stores, into the RAM 32, theposition that is located 185 pixels upstream of the boundary positionBDP in the main scanning direction, as the scanning start position RSP.When storing the home position HP and the scanning start position RSPinto the RAM 32, the CPU 30 sets the position flag PFG to “ON.”Meanwhile, when not storing at least one of the home position HP and thescanning start position RSP into the RAM 32, the CPU 30 sets theposition flag PFG to “OFF.”

The CPU 30 determines whether the position flag PFG is “ON” (U14). Whendetermining that the position flag PFG is “ON” (U14: Yes), the CPU 30goes to the process U5. Meanwhile, when determining that the positionflag PFG is not “ON” (U14: No), the CPU 30 goes to the process U15. Inthe process U15, the CPU 30 transmits, to the display mechanism DM, adisplay instruction to cause the display mechanism DM to display anotification that it is impossible to specify the position of the imagescanner 20. After completion of the process U15, the CPU 30 terminatesthe activating process.

(Precise-Position Detecting Process)

When the precise-position detecting process (U3 or U13) shown in FIG. 6is started, the CPU 30 moves the image scanner 20 just over a distanceof a single line, downstream in the sub scanning direction, and acquiresa single line of gradation values GV (UA1). Specifically, the CPU 30transmits, to the drive circuit 37, a driving instruction to move theimage scanner 20 just over the distance of a single line downstream inthe sub scanning direction. The CPU 30 acquires a gradation value GV ofeach pixel included in the single line by scanning the reference memberBM while keeping the light source 21 turned on with the detection lightquantity DI.

The CPU 30 acquires the first minimum value MN1 (UA2). Specifically, theCPU 30 acquires, as the first minimum value MN1, a minimum one ofgradation values GV within the first range MR1 among the single line ofgradation values GV acquired in the process UA1.

The CPU 30 determines whether the first minimum value MN1 is less thanthe sub position threshold SPTH (UA3). When determining that the firstminimum value MN1 is less than the sub position threshold SPTH (UA3:Yes), the CPU 30 goes to a process UA5. Meanwhile, when determining thatthe first minimum value MN1 is not less than the sub position thresholdSPTH (UA3: No), the CPU 30 goes to a process UA4.

The CPU 30 determines whether the image scanner 20 has moved over afirst particular distance in the repeatedly-executed process UA1 (UA4).When determining that the image scanner 20 has moved over the firstparticular distance (UA4: Yes), the CPU 30 goes to a process UA11.Meanwhile, when determining that the image scanner 20 has not moved overthe first particular distance (UA4: No), the CPU 30 goes to the processUAL In the illustrative embodiment, the first particular distance may bea distance of 90 lines in the sub scanning direction. When the imagescanner 20 moves over the first particular distance (i.e., the distanceof 90 lines) from the home position HP, the image scanner 20 reaches aposition where the image scanner 20 does not face the reference memberBM. The precise-position detecting process (U3 or U13) is a process todetect the sub black-white boundary SSB and the main black-whiteboundary MSB of the reference member BM while moving the image scanner20 downstream from the home position HP in the sub scanning direction.When the image scanner 20 moves over the first particular distance(i.e., the distance of 90 lines) from the home position HP, it denotesthat the reference member BM has not been successfully detected.

When determining that the first minimum value MN1 is less than the subposition threshold SPTH (UA3: Yes), the CPU 30 stores the home positionHP (UA5). Specifically, the CPU 30 stores, into the RAM 32, a positionthat is located 30 lines upstream, in the sub scanning direction, of aposition of the image scanner 20 where it is determined in the processUA3 that the first minimum value MN1 is less than the sub positionthreshold SPTH, as the home position HP.

In response to completion of the process UA5 or the negativedetermination (UA10: No) in the process UA10, the CPU 30 moves the imagescanner 20 just over the distance of a single line, downstream in thesub scanning direction, and acquires a single line of gradation valuesGV (UA6). Specifically, the CPU 30 transmits, to the drive circuit 37, adriving instruction to move the image scanner 20 just over the distanceof a single line downstream in the sub scanning direction. The CPU 30acquires a gradation value GV of each pixel included in the single lineby scanning the reference member BM while keeping the light source 21turned on with the detection light quantity DI.

The CPU 30 determines the boundary position BDP (UA7). Specifically, theCPU 30 searches for a specific pixel at which the gradation value GVbecomes less than the main position threshold MPTH, in the upstreamdirection along the main scanning direction from the 260^(th) pixel inthe main scanning direction, among the single line of gradation valuesGV acquired in the process UA6. The CPU 30 determines a position of thespecific pixel at which the gradation value GV becomes less than themain position threshold MPTH, as a boundary position BDP. In theillustrative embodiment, a range in which the CPU 30 searches for thespecific pixel in the main scanning direction is the third range MR3from the 260^(th) pixel to the 201^(st) pixel.

The CPU 30 acquires the boundary data group BDG (UA8). Specifically, theCPU 30 acquires, as the boundary data group BDG, gradation values GV of10 pixels that are located upstream, in the main scanning direction, ofthe boundary position BDP among the single line of gradation values GVacquired in the process UA6.

The CPU 30 determines whether all of the gradation values GV included inthe boundary data group BDG are less than the main position thresholdMPTH (UA9). When determining that all of the gradation values GVincluded in the boundary data group BDG are less than the main positionthreshold MPTH (UA9: Yes), the CPU 30 goes to a process UA12. Meanwhile,when determining that at least one of the gradation values GV includedin the boundary data group BDG is equal to or more than the mainposition threshold MPTH (UA9: No), the CPU 30 goes to a process UA10.

The CPU 30 determines whether the image scanner 20 has moved over asecond particular distance in the repeatedly-executed process UA6(UA10). When determining that the image scanner 20 has not moved overthe second particular distance (UA10: No), the CPU 30 goes to theprocess UA6. Meanwhile, when determining that the image scanner 20 hasmoved over the second particular distance (UA10: Yes), the CPU 30 goesto the process UA11. In the illustrative embodiment, the secondparticular distance may be a distance of 60 lines in the sub scanningdirection. When the image scanner 20 moves over the second particulardistance (i.e., the distance of 60 lines) from the sub black-whiteboundary SSB, the image scanner 20 reaches a position where the imagescanner 20 does not face the reference member BM. When the image scanner20 moves over the second particular distance (i.e., the distance of 60lines) from the sub black-white boundary SSB, it denotes that thereference member BM has not been successfully detected.

In response to the affirmative determination (UA10: Yes) in the processUA10 or the affirmative determination (UA4: Yes) in the process UA4, theCPU 30 sets the position flag PFG to “OFF” and stores the set value ofthe position flag PFG into the RAM 32 (UA11). After completion of theprocess UA11, the CPU 30 terminates the precise-position detectingprocess (U3 or U13) and returns to the activating process (see FIGS. 5Aand 5B).

When determining that all of the gradation values GV included in theboundary data group BDG are less than the main position threshold MPTH(UA9: Yes), the CPU 30 stores the scanning start position RSP (UA12).Specifically, the CPU 30 stores, into the RAM 32, a position that islocated 185 pixels upstream of the boundary position BDP in the mainscanning direction, as the scanning start position RSP.

The CPU 30 sets the position flag PFG to “ON” and stores the set valueof the position flag PFG into the RAM 32 (UA13). After completion of theprocess UA13, the CPU 30 terminates the precise-position detectingprocess (U3 or U13) and returns to the activating process (see FIGS. 5Aand 5B).

(Rough-Position Detecting Process)

When the rough-position detecting process U6 (see FIGS. 7A and 7B) isstarted, the CPU 30 moves the image scanner 20 just over a distance of 8lines upstream in the sub scanning direction, and acquires a single lineof gradation values GV (UB1). Specifically, the CPU 30 transmits, to thedrive circuit 37, a driving instruction to move the image scanner 20just over the distance of 8 lines upstream in the sub scanningdirection. The CPU 30 acquires a gradation value GV of each pixelincluded in the single line by scanning the reference member BM whilekeeping the light source 21 turned on with the detection light quantityDI. Further, the process UB1 is also performed in response to a negativedetermination (UB5: No) in a below-mentioned process UB5.

The CPU 30 calculates a first average AV1 (UB2). Specifically, the CPU30 calculates the first average AV1 by averaging all of the gradationvalues GV within the first range MR1 among the single line of gradationvalues GV acquired in the process UB1.

The CPU 30 calculates a second average AV2 (UB3). Specifically, the CPU30 calculates the second average AV2 by averaging all of the gradationvalues GV within the second range MR2 among the single line of gradationvalues GV acquired in the process UB1.

The CPU 30 determines whether the first range MR1 is black and thesecond range MR2 is white (UB4). Specifically, when the first averageAV1 is less than the position threshold PTH, and the second average AV2is equal to or more than the position threshold PTH, the CPU 30determines that the first range MR1 is black and that the second rangeMR2 is white (UB4: Yes), and goes to a process UB6. Meanwhile, when thefirst average AV1 is equal to or more than the position threshold PTH,or the second average AV2 is less than the position threshold PTH, theCPU 30 determines that the first range MR1 is not black or that thesecond range MR2 is not white (UB4: No), and goes to a process UB5.

The CPU 30 determines whether the image scanner 20 has moved over athird particular distance or longer in the repeatedly-executed processUB1 (UB5). When determining that the image scanner 20 has moved over thethird particular distance (UB5: Yes), the CPU 30 goes to a process UB12.Meanwhile, when determining that the image scanner 20 has not moved overthe third particular distance (UB5: No), the CPU 30 goes to the processUB1. In the illustrative embodiment, the third particular distance maybe a distance of 3670 lines in the sub scanning direction. When theimage scanner 20 moves upstream in the sub scanning direction over thethird particular distance (i.e., the distance of 3670 lines) from themaximum scanning position MSE, the image scanner 20 reaches the subblack-white boundary SSB. The rough-position detecting process U6 is aprocess to detect the sub black-white boundary SSB of the referencemember BM. When the image scanner 20 moves over the third particulardistance (i.e., the distance of 3670 lines), it denotes that the subblack-white boundary SSB of the reference member BM has not beensuccessfully detected.

When determining that the first range MR1 is black and that the secondrange MR2 is white (UB4: Yes), the CPU 30 stores the black average BAVEand the white average WAVE (UB6). Specifically, the CPU 30 transmits, tothe drive circuit 37, a driving instruction to move the image scanner 20to a position that is located 8 lines upstream in the sub scanningdirection. The CPU 30 acquires a single line of gradation values GV byscanning the reference member BM while keeping the light source 21turned on with the detection light quantity DI. The CPU 30 calculatesthe black average BAVE by averaging all of the gradation values GVwithin the first range MR1 among the acquired single line of gradationvalues GV, and stores the calculated black average BAVE into the RAM 32.The CPU 30 calculates the white average WAVE by averaging all of thegradation values GV within the second range MR2 among the acquiredsingle line of gradation values GV, and stores the calculated whiteaverage WAVE into the RAM 32.

The CPU 30 calculates the black-white difference value BWdif bysubtracting the black average BAVE from the white average WAVE (UB7).

In response to completion of the process UB7 or the negativedetermination (UB12: No) in the process UB12, the CPU 30 moves the imagescanner 20 just over the distance of 8 lines upstream in the subscanning direction, and acquires a single line of gradation values GV(UB8). Specifically, the CPU 30 transmits, to the drive circuit 37, adriving instruction to move the image scanner 20 just over the distanceof 8 lines upstream in the sub scanning direction. The CPU 30 acquires agradation value GV of each pixel included in the single line by scanningthe reference member BM while keeping the light source 21 turned on withthe detection light quantity DI.

The CPU 30 calculates the first average AV1 (UB9). Specifically, the CPU30 calculates the first average AV1 by averaging all of the gradationvalues GV within the first range MR1 among the single line of gradationvalues GV acquired in the process UB8.

The CPU 30 calculates the second average AV2 (UB10). Specifically, theCPU 30 calculates the second average AV2 by averaging all of thegradation values GV within the second range MR2 among the single line ofgradation values GV acquired in the process UB8.

The CPU 30 determines whether the first range MR1 is white and thesecond range MR2 is white (UB11). Specifically, when the first averageAV1 calculated in the process UB9 is equal to or more than the positionthreshold PTH, and the second average AV2 calculated in the process UB10is equal to or more than the position threshold PTH, the CPU 30determines that the first range MR1 is white and that the second rangeMR2 is white (UB11: Yes), and goes to a process UB14. Meanwhile, whenthe first average AV1 calculated in the process UB9 is less than theposition threshold PTH, or the second average AV2 calculated in theprocess UB10 is less than the position threshold PTH, the CPU 30determines that the first range MR1 is not white or that the secondrange MR2 is not white (UB11: No), and goes to a process UB11.

The CPU 30 determines whether the image scanner 20 has moved over afourth particular distance in the repeatedly-executed process UB8(UB12). When determining that the image scanner 20 has not moved overthe fourth particular distance (UB12: No), the CPU 30 goes to theprocess UB8. Meanwhile, when determining that the image scanner 20 hasmoved over the fourth particular distance (UB12: Yes), the CPU 30 goesto a process UB13. In the illustrative embodiment, the fourth particulardistance may be a distance of 56 lines in the sub scanning direction.When the image scanner 20 moves upstream in the sub scanning directionover the fourth particular distance (i.e., the distance of 56 lines)from a most downstream position of the black area BE in the sub scanningdirection, the image scanner 20 reaches the sub black-white boundarySSB. When the image scanner 20 moves over the fourth particular distance(i.e., the distance of 56 lines), it denotes that the sub black-whiteboundary SSB of the reference member BM has not been successfullydetected.

In response to the affirmative determination (UB12: Yes) in the processUB12 or the affirmative determination (UB5: Yes) in the process UB5, theCPU 30 sets the position flag PFG to “OFF” and stores the set value ofthe position flag PFG into the RAM 32 (UB13). After completion of theprocess UB13, the CPU 30 terminates the rough-position detecting processU6, and returns to the activating process (see FIGS. 5A and 5B).

When determining that the first range MR1 is white and that the secondrange MR2 is white (UB11: Yes), the CPU 30 stores the home position HP(UB14). Specifically, the CPU 30 stores, into the RAM 32, a positionthat is located 30 lines upstream, in the sub scanning direction, of aposition of the image scanner 20 where it is determined that the firstrange MR1 is white and that the second range MR2 is white (UB11: Yes),as the home position HP. The CPU 30 transmits, to the drive circuit 37,a driving instruction to move the image scanner 20 to the home positionHP.

The CPU 30 sets the position flag PFG to “ON” and stores the set valueof the position flag PFG into the RAM 32 (UB15). After completion of theprocess UB15, the CPU 30 terminates the rough-position detecting processU6, and returns to the activating process (see FIGS. 5A and 5B).

(Detection Light Quantity Adjusting Process)

When the detection light quantity adjusting process (U10 or D6) shown inFIG. 8 is started, the CPU 30 moves the image scanner 20 to the lightquantity adjustment position IAP (UC1). Specifically, the CPU 30transmits, to the drive circuit 37, a driving instruction to move theimage scanner 20 to the light quantity adjustment position IAP.

The CPU 30 adjusts a quantity of light from the light source 21 (UC2).Specifically, the CPU 30 controls the light source 21 to illuminate thereference member BM while keeping the light source 21 turned on with amaximum electric current value. In this state, the CPU 30 adjusts alighting period of time in such a manner that a minimum one of gradationvalues GV acquired within the second range MR2 when the image scanner 20receives reflected light from the illuminated reference member BMbecomes 255.

The CPU 30 acquires a maximum value within the first range MR1 (UC3).Specifically, the CPU 30 acquires a single line of gradation values GVby scanning the reference member BM while keeping the light source 21turned on with the light quantity adjusted in the process UC2. The CPU30 acquires the maximum one of gradation values GV within the firstrange MR1 among the acquired single line of gradation values GV.

The CPU 30 calculates a first maximum−minimum difference value MXMNdif1(UC4). Specifically, the CPU 30 calculates the first maximum−minimumdifference value MXMNdif1 by subtracting, from the upper limit (i.e.,255) of the 8-bit gradation data, the maximum gradation value GVacquired in the process UC3.

The CPU 30 reduces the quantity of light from the light source 21 by onelevel, and acquires a single line of gradation values GV (UC5).Specifically, the CPU 21 keeps the light source 21 turned on during thelighting period of time shortened by one level. The CPU 30 acquires agradation value GV of each pixel included in the single line by scanningthe reference member BM while keeping the light source 21 turned on withthe light quantity reduced by one level. Thus, in the illustrativeembodiment, the light quantity may be reduced by one level by shorteningthe lighting period of time for keeping the light source 21 turned on,without changing the electrical current supplied to the light source 21.

The CPU 30 acquires a minimum value within the second range MR2 (UC6).Specifically, the CPU 30 acquires the minimum one of gradation values GVwithin the second range MR2 among the single line of gradation values GVacquired in the process UC5.

The CPU 30 acquires a maximum value within the first range MR1 (UC7).Specifically, the CPU 30 acquires the maximum one of gradation values GVwithin the first range MR1 among the single line of gradation values GVacquired in the process UC5.

The CPU 30 calculates a second maximum−minimum difference value MXMNdif2(UC8). Specifically, the CPU 30 calculates the second maximum−minimumdifference value MXMNdif2 by subtracting the maximum gradation value GVacquired in the process UC7 from the minimum gradation value GV acquiredin the process UC6.

The CPU 30 determines whether the second maximum−minimum differencevalue MXMNdif2 is more than the first maximum−minimum difference valueMXMNdif1 (UC9). When determining that the second maximum−minimumdifference value MXMNdif2 is equal to or less than the firstmaximum−minimum difference value MXMNdif1 (UC9: No), the CPU 30 goes toa process UC11. Meanwhile, when determining that the secondmaximum−minimum difference value MXMNdif2 is more than the firstmaximum−minimum difference value MXMNdif1 (UC9: Yes), the CPU 30 goes toa process UC10.

Specifically, when the second maximum−minimum difference value MXMNdif2is more than the first maximum−minimum difference value MXMNdif1 (UC9:Yes), the CPU 30 stores, into the RAM 32, the second maximum−minimumdifference value MXMNdif2 as a first maximum−minimum difference valueMXMNdif1 (UC10). After completion of the process UC10, the CPU 30 goesto the process UC5.

When the second maximum−minimum difference value MXMNdif2 is equal to orless than the first maximum−minimum difference value MXMNdif1 (UC9: No),the CPU 30 acquires, as a detection light quantity DI, the lightquantity reduced by one level in the process UC5 (UC11). In theillustrative embodiment, the detection light quantity DI is determinedby the electrical current supplied to the light source 21 and thelighting period of time during which the light source 21 is kept turnedon, and may be determined by the maximum electrical current and thelighting period of time finally determined in the process UC5. Aftercompletion of the process UC11, the CPU 30 terminates the detectionlight quantity adjusting process (U10 or D6).

(Threshold Calculating Process)

When the threshold calculating process U12 (see FIG. 9) is started, theCPU 30 moves the image scanner 20 to the home position HP (UD1).Specifically, the CPU 30 transmits, to the drive circuit 37, a drivinginstruction to move the image scanner 20 to the home position HP.

The CPU 30 acquires a third data group DG3 of gradation values GV withinthe third storing area ME3 (UD2). Specifically, the CPU 30 transmits, tothe drive circuit 37, a driving instruction to move the image scanner 20to an upstream position that is located 20 lines upstream of the homeposition HP in the sub scanning direction. Then, the CPU 30 transmits,to the drive circuit 37, a driving instruction to move the image scanner20 to a downstream position that is located 40 lines downstream of theupstream position in the sub scanning direction. Thereby, the CPU 30acquires a gradation value GV of each pixel included in each line of 41lines, by scanning the reference member BM on a line-by-line basis withthe light source 21 kept turned on with the detection light quantity DIwhile moving the image scanner 20 to the downstream position. The CPU 30acquires, as the third data group DG3, gradation values GV within thefirst range MR1 among the gradation values GV of the pixels included inthe scanned 41 lines.

The CPU 30 moves the image scanner 20 to the light quantity adjustmentposition IAP (UD3). Specifically, the CPU 30 transmits, to the drivecircuit 37, a driving instruction to move the image scanner 20 to thelight quantity adjustment position IAP.

The CPU 30 acquires gradation values GV within the first storing areaME1 as a first data group DG1, and acquires gradation values GV withinthe second storing area ME2 as a second data group DG2 (UD4).Specifically, the CPU 30 transmits, to the drive circuit 37, a drivinginstruction to move the image scanner 20 to a specific upstream positonthat is located 20 lines upstream of the light quantity adjustmentposition IAP in the sub scanning direction. Then, the CPU 30 transmits,to the drive circuit 37, a driving instruction to move the image scanner20 to a specific downstream position that is located 40 lines downstreamof the specific upstream position in the sub scanning direction.Thereby, the CPU 30 acquires a gradation value GV of each pixel includedin each line of 41 lines, by scanning the reference member BM on aline-by-line basis with the light source 21 kept turned on with thedetection light quantity DI while moving the image scanner 20 to thespecific downstream position. The CPU 30 acquires, as the first datagroup DG1, gradation values GV within the first range MR1 among thegradation values GV of the pixels included in the scanned 41 lines.Further, the CPU 30 acquires, as the second data group DG2, gradationvalues GV within the second range MR2 among the gradation values GV ofthe pixels included in the scanned 41 lines.

The CPU 30 stores the first maximum value MX1 into the flash ROM 33(UD5). Specifically, the CPU 30 stores, into the flash ROM 33, a maximumone of the gradation values GV included in the first data group DG1, asthe first maximum value MX1.

The CPU 30 stores the second minimum value MN2 into the flash ROM 33(UD6). Specifically, the CPU 30 stores, into the flash ROM 33, a minimumone of the gradation values GV included in the second data group DG2, asthe second minimum value MN2.

The CPU 30 stores the third minimum value MN3 into the flash ROM 33(UD7). Specifically, the CPU 30 stores, into the flash ROM 33, a minimumone of the gradation values GV included in the third data group DG3, asthe third minimum value MN3.

The CPU 30 calculates the main position threshold MPTH (UD8).Specifically, the CPU 30 calculates the main position threshold MPTH byaveraging the first maximum value MX1 and the second minimum value MN2.

The CPU 30 calculates the sub position threshold SPTH (UD9).Specifically, the CPU 30 calculates the sub position threshold SPTH byaveraging the first maximum value MX1 and the third minimum value MN3.After completion of the process UD9, the CPU 30 terminates the thresholdcalculating process U12 and returns to the activating process.

(Shutdown Process)

The shutdown process (see FIG. 10) is started in response to a powerbutton 50 of the operation mechanism OM being pressed while the imagescanning apparatus SM is maintained powered on. Namely, the CPU 30starts the shutdown process upon receipt of an instruction issued inresponse to the power button 50 being pressed.

The CPU 30 initializes the device controller 34 and the image processor36 (D1). Specifically, the CPU 30 acquires, from the flash ROM 33,settings for the clock signal CLK and the serial-in signal SI that aresuitable for a scanning resolution of 300 DPI in the main scanningdirection and a scanning resolution of 300 DPI in the sub scanningdirection. Then, the CPU 30 applies the acquired settings to the devicecontroller 34. The CPU 30 acquires, from the flash ROM 33, the detectionlight quantity DI of the light source 21. Then, the CPU 30 applies theacquired detection light quantity DI to the device controller 34. TheCPU 30 configures settings for the black correction into the imageprocessor 36. The CPU 30 acquires black correction data from the flashROM 33, and sets the acquired black correction data into the imageprocessor 36.

The CPU 30 moves the image scanner 20 to the light quantity adjustmentposition IAP and acquires a single line of gradation values GV (D2).Specifically, the CPU 30 transmits, to the drive circuit 37, a drivinginstruction to move the image scanner 20 to the light quantityadjustment position IAP in the sub scanning direction. The CPU 30acquires a gradation value GV of each pixel included in the single lineby scanning the reference member BM while keeping the light source 21turned on with the detection light quantity DI.

The CPU 30 calculates a first average AV1 (D3). Specifically, the CPU 30calculates the first average AV1 by averaging all of the gradationvalues GV within the first range MR1 among the single line of gradationvalues GV acquired in the process D2.

The CPU 30 calculates a second average AV2 (D4). Specifically, the CPU30 calculates the second average AV2 by averaging all of the gradationvalues GV within the second range MR2 among the single line of gradationvalues GV acquired in the process D2.

The CPU 30 determines whether the first average AV1 is less than thefirst threshold TH1 (D5). When determining that the first average AV1 isless than the first threshold TH1 (D5: Yes), the CPU 30 goes to aprocess D7. Meanwhile, when determining that the first average AV1 isnot less than the first threshold TH1 (D5: No), the CPU 30 goes to aprocess D6.

The CPU 30 performs the detection light quantity adjusting process (D6).The detection light quantity adjusting process D6 has been described indetail above. A general outline of the process D6 will be provided here.The CPU 30 transmits, to the drive circuit 37, a driving instruction tomove the image scanner 20 to the light quantity adjustment position IAP.The CPU 30 acquires, as the detection light quantity DI, a lightquantity adjusted to maximize a value obtained by subtracting a maximumone of the gradation values GV within the first range MR1 from a minimumone of the gradation values GV within the second range MR2. The CPU 30stores the acquired detection light quantity DI into the flash ROM 33.

The CPU 30 determines whether the second average AV2 is equal to or morethan the second threshold TH2 (D7). When determining that the secondaverage AV2 is not equal to or more than the second threshold TH2 (D7:No), the CPU 30 goes to a process D8. When determining that the secondaverage AV2 is equal to or more than the second threshold TH2 (D7: Yes),the CPU 30 goes to a process D9.

The CPU 30 stores the first maximum value MX1 and the second minimumvalue MN2 (D8). The storing process D8 will be described in detaillater. A general outline of the process D8 will be provided here. TheCPU 30 transmits, to the drive circuit 37, a driving instruction to movethe image scanner 20 to the light quantity adjustment position IAP. TheCPU 30 acquires gradation values GV within the first storing area ME1 asthe first data group DG1, and acquires gradation values GV within thesecond storing area ME2 as the second data group DG2. The CPU 30 stores,into the flash ROM 33, a maximum one of the gradation values GV includedin the acquired first data group DG1, as the first maximum value MX1.Further, the CPU 30 stores, into the flash ROM 33, a minimum one of thegradation values GV included in the acquired second data group DG2, asthe second maximum value MN2. After completion of the process D8, theCPU 30 turns off the image scanning apparatus SM (D9). After completionof the process D9, the shutdown process is terminated.

(Storing Process)

When the storing process D8 (see FIG. 11) to store the first maximumvalue MX1 and the second minimum value MN2 is started, the CPU 30 movesthe image scanner 20 to the light quantity adjustment position IAP(DA1). Specifically, the CPU 30 transmits, to the drive circuit 37, adriving instruction to move the image scanner 20 to the light quantityadjustment position IAP.

The CPU 30 acquires gradation values GV within the first storing areaME1 as the first data group DG1, and acquires gradation values GV withinthe second storing area ME2 as the second data group DG2 (DA2).Specifically, the CPU 30 transmits, to the drive circuit 37, a drivinginstruction to move the image scanner 20 to a specific upstream positionthat is located 20 lines upstream of the light quantity adjustmentposition IAP in the sub scanning direction. Then, the CPU 30 transmits,to the drive circuit 37, a driving instruction to move the image scanner20 to a specific downstream position that is located 40 lines downstreamof the specific upstream position in the sub scanning direction.Thereby, the CPU 30 acquires a gradation value GV of each pixel includedin each line of 41 lines, by scanning the reference member BM on aline-by-line basis with the light source 21 kept turned on with thedetection light quantity DI while moving the image scanner 20 to thespecific downstream position. The CPU 30 acquires, as the first datagroup DG1, gradation values GV within the first range MR1 among thegradation values GV of the pixels included in the scanned 41 lines.Further, the CPU 30 acquires, as the second data group DG2, gradationvalues GV within the second range MR2 among the gradation values GV ofthe pixels included in the scanned 41 lines.

The CPU 30 stores the first maximum value MX1 into the flash ROM 33(DA3). Specifically, the CPU 30 stores, into the flash ROM 33, a maximumone of the gradation values GV included in the first data group DG1acquired in the process DA2, as the first maximum value MX1.

The CPU 30 stores the second minimum value MN2 into the flash ROM 33(DA4). Specifically, the CPU 30 stores, into the flash ROM 33, a minimumone of the gradation values GV included in the second data group DG2acquired in the process DA2, as the second minimum value MN2. Aftercompletion of the process DA4, the CPU 30 terminates the storing processD8.

<Advantageous Effects in Illustrative Embodiment>

In the illustrative embodiment, in the process U8, the CPU 30 determineswhether the black average BAVE is less than the first threshold TH1.When determining that the black average BAVE is not less than the firstthreshold TH1 (i.e., when the black average BAVE is equal to or morethan the first threshold TH1) (U8: No), the CPU 30 goes to the processU10. In the process U9, the CPU 30 determines whether the differencebetween the black-white difference value BWdif and the positionthreshold PTH is equal to or more than the third threshold TH3. Whendetermining that the difference between the black-white difference valueBWdif and the position threshold PTH is not equal to or more than thethird threshold TH3 (i.e., when the difference between the black-whitedifference value BWdif and the position threshold PTH is less than thethird threshold TH3) (U9: No), the CPU 30 goes to the process U10. Inthe process U10, the CPU 30 moves the image scanner 20 to the lightquantity adjustment position IAP. Then, the CPU 30 acquires, thedetection light quantity DI, a light quantity adjusted to maximize avalue obtained by subtracting a maximum one of the gradation values GVincluded in the first range MR1 from a minimum one of the gradationvalues GV included in the second range MR2. The CPU 30 stores theacquired detection light quantity DI into the flash ROM 33. Hence, whenthe black average BAVE, which is an average of gradation values GVacquired by scanning the black area BE, is not less than the firstthreshold TH1, the black average BAVE may become higher due to colordegradation of the black area BE. Even in such a case, by adjusting thedetection light quantity DI for detecting the reference member BM, it ispossible to accurately detect the reference member BM. Further, when thedifference between the black-white difference value BWdif and theposition threshold PTH is less than the third threshold TH3, such asecular change that the white average WAVE decreases due to aging of thelight source 21 and such a secular change that the black average BAVEincreases due to color degradation of the black area BE may concurrentlyoccur. Even in this case, by adjusting the detection light quantity DIfor detecting the reference member BM, it is possible to accuratelydetect the reference member BM.

In the process U11, the CPU 30 determines whether the white average WAVEis equal to or more than the second threshold TH2. When determining thatthe white average WAVE is not equal to or more than the second thresholdTH2 (i.e., when the white average WAVE is less the second threshold TH2)(U11: No), the CPU 30 goes to the process U12. In response to completionof the process U10 or the negative determination (U11: No) in theprocess U11, the CPU 30 calculates the main position threshold MPTH andthe sub position threshold SPTH in the process U12. Hence, when thewhite average WAVE is not equal to or more than the second thresholdTH2, the white average WAVE may become lower due to a secular change ofthe light source 21. Even in such a case, by calculating the mainposition MPTH and the sub position threshold SPTH, it is possible toaccurately detect the reference member BM. Further, in the illustrativeembodiment, after adjusting the detection light quantity DI in theprocess U10, the CPU 30 acquires the first data group DG, the seconddata group DG2, and the third data group DG3, using the adjusteddetection light quantity DI. Thereby, it is possible to accuratelydetect the reference member BM.

In the shutdown process, the CPU 30 determines in the process D5 whetherthe first average AV1 is less than the first threshold TH1. Whendetermining that the first average AV1 is not less than the firstthreshold TH1 (i.e., when the first average AV1 is equal to or more thanthe first threshold TH1) (D5: No), the CPU 30 goes to the process D6. Inthe process D6, the CPU 30 moves the image scanner 20 to the lightquantity adjustment position IAP. Further, the CPU 30 acquires, as thedetection light quantity DI, a light quantity adjusted to maximize avalue obtained by subtracting a maximum one of the gradation values GVwithin the first range MR1 from a minimum one of the gradation values GVwithin the second range MR2. The CPU 30 stores the acquired detectionlight quantity DI into the flash ROM 33. Hence, when the first averageAV1, which is an average of gradation values GV acquired by scanning theblack area BE, is not less than the first threshold TH1, the firstaverage AV1 may become higher due to color degradation of the black areaBE. Even in such a case, by adjusting the detection light quantity DIfor detecting the reference member BM, it is possible to accuratelydetect the reference member BM. Further, by adjusting the detectionlight quantity DI in the shutdown process, it is possible to accuratelydetect the reference member BM next time the image scanning apparatus SMis powered on.

In the shutdown process, the CPU 30 determines in the process D7 whetherthe second average AV2 is equal to or more than the second thresholdTH2. When determining that the second average AV2 is not equal to ormore than the second threshold TH2 (i.e., when the second average AV2 isless than the second threshold TH2) (D7: No), the CPU 30 goes to theprocess D8. In the process D8, the CPU 30 stores the first maximum valueMX1 and the second minimum value MN2 into the flash ROM 33. Hence, whenthe second average AV2 is not equal to or more than the second thresholdTH2, the second average AV2 may become lower due to a secular change ofthe light source 21. Even in such a case, by storing the first maximumvalue MX1 and the second minimum value MN2 into the flash ROM 33, it ispossible to, next time the image scanning apparatus SM is powered on,accurately calculate the position threshold PTH and thereby accuratelydetect the reference member BM.

Hereinabove, the illustrative embodiment according to aspects of thepresent disclosure has been described. The present disclosure can bepracticed by employing conventional materials, methodology andequipment. Accordingly, the details of such materials, equipment andmethodology are not set forth herein in detail. In the previousdescriptions, numerous specific details are set forth, such as specificmaterials, structures, chemicals, processes, etc., in order to provide athorough understanding of the present disclosure. However, it should berecognized that the present disclosure can be practiced withoutreapportioning to the details specifically set forth. In otherinstances, well known processing structures have not been described indetail, in order not to unnecessarily obscure the present disclosure.

Only an exemplary illustrative embodiment of the present disclosure andbut a few examples of its versatility are shown and described in thepresent disclosure. It is to be understood that the present disclosureis capable of use in various other combinations and environments and iscapable of changes or modifications within the scope of the inventiveconcept as expressed herein. For instance, according to aspects of thepresent disclosure, the following modifications are possible.

The image scanning apparatus SM according to aspects of the presentdisclosure may be applied to a multi-function peripheral including aprinter. In the aforementioned illustrative embodiment, the imagescanner 20 including the CIS has been exemplified. Nonetheless, theimage scanner 20 may include a CCD unit configured to move along the subscanning direction with a CCD mounted thereon, or may include a scanningunit having an image sensor configured such that only a light source anda mirror are movable along the sub scanning direction.

In the aforementioned illustrative embodiment, the black area BE isdisposed at a position that is a most downstream position of thereference member BM in the sub scanning direction and is a most upstreamposition of the reference member BM in the main scanning direction.Nonetheless, the black area BE may be disposed at a different position.Further, in the aforementioned illustrative embodiment, the black areaBE is formed in a rectangular shape. Nonetheless, the black area BE maybe formed in a different shape (e.g., a round shape, an oval shape, anda polygonal shape other than the rectangular shape). Moreover, in theaforementioned illustrative embodiment, the number of the black area(s)BE is one. Nonetheless, two or more black areas BE may be provided.

In the aforementioned illustrative embodiment, the quantity of lightemitted by the light source 21 is adjusted by the lighting period oftime during which the light source 21 is kept turned on. Nonetheless,the light quantity of the light source 21 may be adjusted by theelectrical current to be supplied to the light source 21, or may beadjusted by both the lighting period of time and the electrical current.

In the aforementioned illustrative embodiment, the first threshold TH1is set to 30, which is a maximum value of varying gradation values GVacquired by single-line scanning of the black color along the mainscanning direction. Nonetheless, the first threshold TH1 may be set to adifferent value such as an average of varying gradation values GVacquired by single-line scanning of the black color along the mainscanning direction. Further, since gradation values GV acquired byscanning of the black color vary depending on an environmentaltemperature, the first threshold TH1 may be set to a higher value as theenvironmental temperature increases and may be set to a lower value asthe environmental temperature decreases.

In the aforementioned illustrative embodiment, the second threshold TH2is set to 127, which is an integer part of 255 (i.e., the upper limit ofthe 8-bit gradation data) divided by 2. Nonetheless, the secondthreshold TH2 may be set to a different value. For instance, gradationvalues GV acquired by scanning of the white color are significantlyinfluenced by unevenness of the light quantity of the light source 21.Further, the unevenness of the light quantity of the light source 21differs depending on an individual difference of the image scanner 20.Therefore, the second threshold TH2 may be individually set according tothe unevenness of the light quantity of the light source 21 beforeshipment of the image scanning apparatus SM.

In the aforementioned illustrative embodiment, the third threshold TH3is set to 25, which is about 10% of 255 (i.e., the upper limit of the8-bit gradation data). Nonetheless, the third threshold TH3 may be setto a different value. For instance, when it is previously known that theimage scanning apparatus SM will not be used for a long time, the CPU 30might fail to detect the reference member BM. In this case, the thirdthreshold TH3 may be set to a lower value, and preferably, the detectionlight quantity DI, the first maximum value MX1, and the second minimumvalue MN2 may be reacquired.

In the aforementioned illustrative embodiment, in the process UB6, theCPU 30 calculates the black average BAVE and the white average WAVE froma single line of gradation values GV acquired in a position to which theimage scanner 20 is moved over a distance of 8 lines upstream in the subscanning direction from a position where it is determined in the processUB4 that the first range MR1 is black and that the second range MR2 iswhite. Nonetheless, the CPU 30 may calculate the black average BAVE andthe white average WAVE from a single line of gradation values GVacquired in a different position. For instance, the CPU 30 may calculatethe black average BAVE and the white average WAVE from a single line ofgradation values GV acquired in any position between a 30^(th)-lineposition and a 90^(th)-line position that are downstream of the homeposition HP in the sub scanning direction.

In the aforementioned illustrative embodiment, the CPU 30 determineswhether to perform the detection light quantity adjusting process, bydetermining whether the black average BAVE is less than the firstthreshold TH1. Nonetheless, the CPU 30 may determine whether to performthe detection light quantity adjusting process, in a different method.For instance, the CPU may perform the detection light quantity adjustingprocess when the black average BAVE greatly changes.

In the aforementioned illustrative embodiment, in the process UD8, theCPU 30 calculates the main position threshold MPTH by averaging thefirst maximum value MX1 and the second minimum value MN2. Nonetheless,the CPU 30 may calculate the main position threshold MPTH in a differentmethod. For instance, the CPU 30 may determine the main positionthreshold MPTH as an intermediate value between the first maximum valueMX1 and the second minimum value MN2.

In the aforementioned illustrative embodiment, in the process UD9, theCPU 30 calculates the sub position threshold SPTH by averaging the firstmaximum value MX1 and the third minimum value MN3. Nonetheless, the CPU30 may calculate the sub position threshold SPTH in a different method.For instance, the CPU 30 may determine the sub position threshold SPTHas an intermediate value between the first maximum value MX1 and thethird minimum value MN3.

Associations between elements exemplified in the aforementionedillustrative embodiment and elements according to aspects of the presentdisclosure will be exemplified below. The image scanning apparatus SMmay be an example of an “image scanning apparatus” according to aspectsof the present disclosure. The reference member BM may be an example ofa “reference member” according to aspects of the present disclosure. Theimage scanner 20, the AFE 35, and the image processor 36 may be includedin an “image scanner” according to aspects of the present disclosure.The drive circuit 37, the carrying motor MT, and the moving mechanism MMmay be included in a “mover” according to aspects of the presentdisclosure. The RAM 32 and the flash ROM 33 may be included in a“storage” according to aspects of the present disclosure. The CPU 30 andthe ROM 31 storing the programs 31A may be included in a “controller”according to aspects of the present disclosure. Each of the processesU8, U9, and D5 may be an example of a “light quantity adjustmentdetermining process” according to aspects of the present disclosure.Each of the processes U10 and D6 may be an example of a “light quantityadjusting process” according to aspects of the present disclosure. Theprocess U12 may be an example of a “threshold calculating process”according to aspects of the present disclosure. Each of the processesU3, U6, and U13 may be an example of a “reference position detectingprocess” according to aspects of the present disclosure. The processesUD4 and UD5 may be included in an exemplary procedure of a “black valueacquiring process” according to aspects of the present disclosure.Further, the processes DA2 and DA3 may be included in an exemplaryprocedure of the “black value acquiring process” according to aspects ofthe present disclosure. The processes UD4, UD6, and UD7 may be includedin an exemplary procedure of a “white value acquiring process” accordingto aspects of the present disclosure. Further, the processes DA2 and DA4may be included in an exemplary procedure of the “white value acquiringprocess” according to aspects of the present disclosure. Each of theprocesses U11 and D7 may be an example of a “reacquisition determiningprocess” according to aspects of the present disclosure. The process UB6may be an example of a “black average acquiring process” according toaspects of the present disclosure. Further, the processes D2 and D3 maybe included in an exemplary procedure of the “black average acquiringprocess” according to aspects of the present disclosure. Each of theprocesses U8 and D5 may be an example of a “black determining process”according to aspects of the present disclosure. The process UB6 may bean example of a “white average acquiring process” according to aspectsof the present disclosure. Further, the processes D2 and D4 may beincluded in an exemplary procedure of the “white average acquiringprocess” according to aspects of the present disclosure. Each of theprocesses U11 and D7 may be an example of a “white determining process”according to aspects of the present disclosure. The process U2 may be anexample of a “pre-adjustment threshold calculating process” according toaspects of the present disclosure. The process UB7 may be an example ofa “black-white difference calculating process” according to aspects ofthe present disclosure. The process U9 may be an example of a“black-white difference determining process” according to aspects of thepresent disclosure. The shutdown process shown in FIG. 10 may be anexample of a “shutdown process” according to aspects of the presentdisclosure.

What is claimed is:
 1. An image scanning apparatus comprising: an imagescanner comprising a light source and a light receiver, the lightreceiver comprising light receiving elements arranged in line along amain scanning direction, the image scanner being configured toilluminate a scanned target with light emitted by the light source andreceive reflected light from the scanned target by the light receiver,thereby generating gradation values; a mover configured to move theimage scanner along a sub scanning direction perpendicular to the mainscanning direction; a reference member comprising a black portion, awhite portion, and a black-white boundary between the black portion andthe white portion, a position of the black-white boundary being areference position for the image scanner in the main scanning directionor the sub scanning direction; a storage configured to store a detectionlight quantity, the detection light quantity being a quantity of lightto be emitted by the light source to detect the reference position; anda controller configured to perform: a light quantity adjustmentdetermining process to determine whether the detection light quantityneeds to be adjusted, based on adjustment determination values, theadjustment determination values being gradation values generated whenthe image scanner illuminates the reference member with the detectionlight quantity in a black-white detectable position, the black-whitedetectable position being a position in the sub scanning direction wherethe image scanner faces the black portion and the white portion; a lightquantity adjusting process comprising: in response to determining thatthe detection light quantity needs to be adjusted, adjusting thedetection light quantity to maximize an adjustment difference value, theadjustment difference value being a difference between a gradation valuegenerated when the image scanner scans the white portion whileilluminating the reference member in the black-white detectable positionand a gradation value generated when the image scanner scans the blackportion while illuminating the reference member in the black-whitedetectable position; and storing the adjusted detection light quantityinto the storage; a threshold calculating process to calculate adetection threshold based on a black value and a white value, the blackvalue being a gradation value generated when the image scanner scans theblack portion, the white value being a gradation value generated whenthe image scanner scans the white portion; and a reference positiondetecting process to, while moving the image scanner along the subscanning direction by the mover, detect the reference position bycomparing, with the detection threshold, gradation values generated whenthe image scanner scans the reference member while illuminating thereference member with the detection light quantity stored in thestorage.
 2. The image scanning apparatus according to claim 1, whereinthe storage is further configured to store the black value and the whitevalue, and wherein the threshold calculating process comprises: a blackvalue acquiring process comprising: after adjusting the detection lightquantity in response to determining that the detection light quantityneeds to be adjusted, acquiring, as the black value, a maximum one ofgradation values within a particular black area of the black portionamong gradation values generated when the image scanner scans the blackportion while illuminating the reference member with the adjusteddetection light quantity; and storing the acquired black value into thestorage; a white value acquiring process comprising: after adjusting thedetection light quantity in response to determining that the detectionlight quantity needs to be adjusted, acquiring, as the white value, aminimum one of gradation values within a particular white area of thewhite portion among gradation values generated when the image scannerscans the white portion while illuminating the reference member with theadjusted detection light quantity; and storing the acquired white valueinto the storage; and calculating, as the detection threshold, anaverage of the black value stored in the storage and the white valuestored in the storage.
 3. The image scanning apparatus according toclaim 2, wherein the controller is further configured to perform: areacquisition determining process to, in response to determining thatthe detection light quantity does not need to be adjusted, determinewhether the black value and the white value need to be acquired, basedon a reacquisition determination value, the reacquisition determinationvalue being a gradation value generated when the image scanner scans thereference member while illuminating the reference member with thedetection light quantity stored in the storage, in the black-whitedetectable position, wherein the black value acquiring processcomprises: in response to determining that the black value and the whitevalue need to be acquired, acquiring, as the black value, a maximum oneof gradation values within the particular black area of the blackportion among gradation values generated when the image scanner scansthe black portion while illuminating the reference member with thedetection light quantity stored in the storage; and storing the acquiredblack value into the storage, and wherein the white value acquiringprocess comprises: in response to determining that the black value andthe white value need to be acquired, acquiring, as the white value, aminimum one of gradation values within the particular white area of thewhite portion among gradation values generated when the image scannerscans the white portion while illuminating the reference member with thedetection light quantity stored in the storage; and storing the acquiredwhite value into the storage.
 4. The image scanning apparatus accordingto claim 3, wherein the light quantity adjustment determining processcomprises: a black average acquiring process comprising: acquiring ablack average as one of the adjustment determination values, the blackaverage being an average of gradation values within a first range amonga single line of gradation values generated when the image scanner scansthe reference member along the main scanning direction in theblack-white detectable position, the first range corresponding to aposition of the black portion in the main scanning direction; andstoring the acquired black average into the storage; a black determiningprocess to determine whether the black average is less than a firstthreshold, the first threshold being a maximum one of varying gradationvalues generated when the image scanner performs single-line scanning ofa black color along the main scanning direction; and in response todetermining that the black average is equal to or more than the firstthreshold, determining that the detection light quantity needs to beadjusted; and in response to determining that the black average is lessthan the first threshold, determining that the detection light quantitydoes not need to be adjusted.
 5. The image scanning apparatus accordingto claim 4, wherein the reacquisition determining process comprises: awhite average acquiring process comprising: acquiring a white average asthe reacquisition determination value, the white average being anaverage of gradation values within a second range among a single line ofgradation values generated when the image scanner scans the referencemember along the main scanning direction in the black-white detectableposition, the second range corresponding to a position of the whiteportion in the main scanning direction; and storing the acquired whiteaverage into the storage; a white determining process to determinewhether the reacquisition determination value is equal to or more than asecond threshold, the second threshold being an integer part of a valueobtained by dividing an upper limit of gradation values generable by theimage scanner by two; and in response to determining that thereacquisition determination value is less than the second threshold,determining that the black value and the white value need to beacquired; and in response to determining that the reacquisitiondetermination value is equal to or more than the second threshold,determining that the black value or the white value does not need to beacquired.
 6. The image scanning apparatus according to claim 5, whereinthe controller is further configured to perform: a pre-adjustmentthreshold calculating process to, before execution of the light quantityadjustment determining process, calculate, as a pre-adjustment detectionthreshold, an average of the black color and the white color stored inthe storage, wherein the light quantity adjustment determining processcomprises: a black-white difference calculating process comprising:calculating, as one of the adjustment determination values, ablack-white difference value by subtracting the black average from thewhite average; and storing the calculated black-white difference valueinto the storage; a black-white difference determining process todetermine whether a difference between the black-white difference valueand the pre-adjustment detection threshold is equal to or more than athird threshold, the third threshold being substantially 10% of a countof gradations for the gradation values generable by the image scanner;in response to determining that the difference between the black-whitedifference value and the pre-adjustment detection threshold is less thanthe third threshold, determining that the detection light quantity needsto be adjusted; and in response to determining that the differencebetween the black-white difference value and the pre-adjustmentdetection threshold is equal to or more than the third threshold,determining that the detection light quantity does not need to beadjusted.
 7. The image scanning apparatus according to claim 6, furthercomprising an operable power switch, wherein the controller is furtherconfigured to perform: a shutdown process to, in response to the powerswitch being operated, after execution of the light quantity adjustmentdetermining process, the reacquisition determining process, the lightquantity adjusting process, and the threshold calculating process, poweroff the image scanning apparatus.
 8. The image scanning apparatusaccording to claim 1, wherein the controller comprises: a processor; anda memory storing processor-executable instructions configured to, whenexecuted by the processor, cause the processor to perform the lightquantity adjustment determining process, the light quantity adjustingprocess, the threshold calculating process, and the reference positiondetecting process.
 9. A method implementable on a processor coupled withan image scanning apparatus, the image scanning apparatus comprising: animage scanner comprising a light source and a light receiver, the lightreceiver comprising light receiving elements arranged in line along amain scanning direction, the image scanner being configured toilluminate a scanned target with light emitted by the light source andreceive reflected light from the scanned target by the light receiver,thereby generating gradation values; a mover configured to move theimage scanner along a sub scanning direction perpendicular to the mainscanning direction; a reference member comprising a black portion, awhite portion, and a black-white boundary between the black portion andthe white portion, a position of the black-white boundary being areference position for the image scanner in the main scanning directionor the sub scanning direction; and a storage configured to store adetection light quantity, the detection light quantity being a quantityof light to be emitted by the light source to detect the referenceposition, the method comprising: determining whether the detection lightquantity needs to be adjusted, based on adjustment determination values,the adjustment determination values being gradation values generatedwhen the image scanner illuminates the reference member with thedetection light quantity in a black-white detectable position, theblack-white detectable position being a position in the sub scanningdirection where the image scanner faces the black portion and the whiteportion; in response to determining that the detection light quantityneeds to be adjusted, adjusting the detection light quantity to maximizean adjustment difference value, the adjustment difference value being adifference between a gradation value generated when the image scannerscans the white portion while illuminating the reference member in theblack-white detectable position and a gradation value generated when theimage scanner scans the black portion while illuminating the referencemember in the black-white detectable position; storing the adjusteddetection light quantity into the storage; calculating a detectionthreshold based on a black value and a white value, the black valuebeing a gradation value generated when the image scanner scans the blackportion, the white value being a gradation value generated when theimage scanner scans the white portion; and while moving the imagescanner along the sub scanning direction by the mover, detecting thereference position by comparing, with the detection threshold, gradationvalues generated when the image scanner scans the reference member whileilluminating the reference member with the detection light quantitystored in the storage.
 10. A non-transitory computer-readable mediumstoring computer-readable instructions that are executable by aprocessor coupled with an image scanning apparatus, the image scanningapparatus comprising: an image scanner comprising a light source and alight receiver, the light receiver comprising light receiving elementsarranged in line along a main scanning direction, the image scannerbeing configured to illuminate a scanned target with light emitted bythe light source and receive reflected light from the scanned target bythe light receiver, thereby generating gradation values; a moverconfigured to move the image scanner along a sub scanning directionperpendicular to the main scanning direction; a reference membercomprising a black portion, a white portion, and a black-white boundarybetween the black portion and the white portion, a position of theblack-white boundary being a reference position for the image scanner inthe main scanning direction or the sub scanning direction; and a storageconfigured to store a detection light quantity, the detection lightquantity being a quantity of light to be emitted by the light source todetect the reference position, the instructions being configured to,when executed by the processor, cause the processor to perform: a lightquantity adjustment determining process to determine whether thedetection light quantity needs to be adjusted, based on adjustmentdetermination values, the adjustment determination values beinggradation values generated when the image scanner illuminates thereference member with the detection light quantity in a black-whitedetectable position, the black-white detectable position being aposition in the sub scanning direction where the image scanner faces theblack portion and the white portion; a light quantity adjusting processcomprising: in response to determining that the detection light quantityneeds to be adjusted, adjusting the detection light quantity to maximizean adjustment difference value, the adjustment difference value being adifference between a gradation value generated when the image scannerscans the white portion while illuminating the reference member in theblack-white detectable position and a gradation value generated when theimage scanner scans the black portion while illuminating the referencemember in the black-white detectable position; and storing the adjusteddetection light quantity into the storage; a threshold calculatingprocess to calculate a detection threshold based on a black value and awhite value, the black value being a gradation value generated when theimage scanner scans the black portion, the white value being a gradationvalue generated when the image scanner scans the white portion; and areference position detecting process to, while moving the image scanneralong the sub scanning direction by the mover, detect the referenceposition by comparing, with the detection threshold, gradation valuesgenerated when the image scanner scans the reference member whileilluminating the reference member with the detection light quantitystored in the storage.
 11. The non-transitory computer-readable mediumaccording to claim 10, wherein the storage is further configured tostore the black value and the white value, and wherein the thresholdcalculating process comprises: a black value acquiring processcomprising: after adjusting the detection light quantity in response todetermining that the detection light quantity needs to be adjusted,acquiring, as the black value, a maximum one of gradation values withina particular black area of the black portion among gradation valuesgenerated when the image scanner scans the black portion whileilluminating the reference member with the adjusted detection lightquantity; and storing the acquired black value into the storage; a whitevalue acquiring process comprising: after adjusting the detection lightquantity in response to determining that the detection light quantityneeds to be adjusted, acquiring, as the white value, a minimum one ofgradation values within a particular white area of the white portionamong gradation values generated when the image scanner scans the whiteportion while illuminating the reference member with the adjusteddetection light quantity; and storing the acquired white value into thestorage; and calculating, as the detection threshold, an average of theblack value stored in the storage and the white value stored in thestorage.
 12. The non-transitory computer-readable medium according toclaim 11, wherein the instructions are further configured to, whenexecuted by the processor, cause the processor to perform: areacquisition determining process to, in response to determining thatthe detection light quantity does not need to be adjusted, determinewhether the black value and the white value need to be acquired, basedon a reacquisition determination value, the reacquisition determinationvalue being a gradation value generated when the image scanner scans thereference member while illuminating the reference member with thedetection light quantity stored in the storage, in the black-whitedetectable position, wherein the black value acquiring processcomprises: in response to determining that the black value and the whitevalue need to be acquired, acquiring, as the black value, a maximum oneof gradation values within the particular black area of the blackportion among gradation values generated when the image scanner scansthe black portion while illuminating the reference member with thedetection light quantity stored in the storage; and storing the acquiredblack value into the storage, and wherein the white value acquiringprocess comprises: in response to determining that the black value andthe white value need to be acquired, acquiring, as the white value, aminimum one of gradation values within the particular white area of thewhite portion among gradation values generated when the image scannerscans the white portion while illuminating the reference member with thedetection light quantity stored in the storage; and storing the acquiredwhite value into the storage.
 13. The image scanning apparatus accordingto claim 3, wherein the light quantity adjustment determining processcomprises: a black average acquiring process comprising: acquiring ablack average as one of the adjustment determination values, the blackaverage being an average of gradation values within a first range amonga single line of gradation values generated when the image scanner scansthe reference member along the main scanning direction in theblack-white detectable position, the first range corresponding to aposition of the black portion in the main scanning direction; andstoring the acquired black average into the storage; a black determiningprocess to determine whether the black average is less than a firstthreshold, the first threshold being a maximum one of varying gradationvalues generated when the image scanner performs single-line scanning ofa black color along the main scanning direction; and in response todetermining that the black average is equal to or more than the firstthreshold, determining that the detection light quantity needs to beadjusted; and in response to determining that the black average is lessthan the first threshold, determining that the detection light quantitydoes not need to be adjusted.
 14. The non-transitory computer-readablemedium according to claim 13, wherein the reacquisition determiningprocess comprises: a white average acquiring process comprising:acquiring a white average as the reacquisition determination value, thewhite average being an average of gradation values within a second rangeamong a single line of gradation values generated when the image scannerscans the reference member along the main scanning direction in theblack-white detectable position, the second range corresponding to aposition of the white portion in the main scanning direction; andstoring the acquired white average into the storage; a white determiningprocess to determine whether the reacquisition determination value isequal to or more than a second threshold, the second threshold being aninteger part of a value obtained by dividing an upper limit of gradationvalues generable by the image scanner by two; and in response todetermining that the reacquisition determination value is less than thesecond threshold, determining that the black value and the white valueneed to be acquired; and in response to determining that thereacquisition determination value is equal to or more than the secondthreshold, determining that the black value or the white value does notneed to be acquired.
 15. The non-transitory computer-readable mediumaccording to claim 14, wherein the instructions are further configuredto, when executed by the processor, cause the processor to perform: apre-adjustment threshold calculating process to, before execution of thelight quantity adjustment determining process, calculate, as apre-adjustment detection threshold, an average of the black color andthe white color stored in the storage, wherein the light quantityadjustment determining process comprises: a black-white differencecalculating process comprising: calculating, as one of the adjustmentdetermination values, a black-white difference value by subtracting theblack average from the white average; and storing the calculatedblack-white difference value into the storage; a black-white differencedetermining process to determine whether a difference between theblack-white difference value and the pre-adjustment detection thresholdis equal to or more than a third threshold, the third threshold beingsubstantially 10% of a count of gradations for the gradation valuesgenerable by the image scanner; in response to determining that thedifference between the black-white difference value and thepre-adjustment detection threshold is less than the third threshold,determining that the detection light quantity needs to be adjusted; andin response to determining that the difference between the black-whitedifference value and the pre-adjustment detection threshold is equal toor more than the third threshold, determining that the detection lightquantity does not need to be adjusted.
 16. The non-transitorycomputer-readable medium according to claim 15, further comprising anoperable power switch, wherein the instructions are further configuredto, when executed by the processor, cause the processor to perform: ashutdown process to, in response to the power switch being operated,after execution of the light quantity adjustment determining process,the reacquisition determining process, the light quantity adjustingprocess, and the threshold calculating process, power off the imagescanning apparatus.